// 这个是用户相关的 vuex 模块
import { getUserInfoAPI } from '@/api/user.js'
export default {
  namespaced: true,
  state() {
    return {
      token: '',
      info: {}
    }
  },
  mutations: {
    updateToken(state, token) {
      state.token = token
    },
    updateInfo(state, obj) {
      state.info = obj
    }
  },
  actions: {
    async initUserInfo(ctx) {
      const result = await getUserInfoAPI()
      // console.log(result)
      ctx.commit('updateInfo', result.data)
    }
  }
}
